/*
 * Student.java
 * 
 * Copyright©2012-2013 JMAS corporation. All rights reserved.
 */
package jp.co.jmas.jmasvideo.dao;

import java.io.Serializable;

public class Student implements Serializable {
	/** Serial ID */
	private static final long serialVersionUID = 1L;

	private String key;

	private String name;

	private String kana;

	private Gender gender;

	private String email;

	/** belong class */
	transient private ClassInfo classInfo;

	/**
	 * @return the key
	 */
	public String getKey() {
		return key;
	}

	/**
	 * @param key the key to set
	 */
	public void setKey(String key) {
		this.key = key;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	public String getKana() {
		return kana;
	}

	public void setKana(String kana) {
		this.kana = kana;
	}

	public Gender getGender() {
		return gender;
	}

	public void setGender(Gender gender) {
		this.gender = gender;
	}

	/**
	 * @return the email
	 */
	public String getEmail() {
		return email;
	}

	/**
	 * @param email the email to set
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	public ClassInfo getClassInfo() {
		return classInfo;
	}

	public void setClassInfo(ClassInfo classInfo) {
		this.classInfo = classInfo;
	}

	/**
	 * 名前とemailが一致した場合、同一オブジェクトと判断する。(同名や双子を想定)
	 */
	@Override
	public boolean equals(Object o) {
		if (o instanceof Student) {
			Student target = (Student)o;
			return name.equals(target.getName()) && email.equals(target.getEmail());
		}
		return (o instanceof Student) && name.equals(((Student)o).getName());
	}

	@Override
	public int hashCode() {
		return name.hashCode() + email.hashCode();
	}
}
